<?php

/**
 * event actions.
 *
 * @package    Nika
 * @subpackage event
 * @author     Alexey Shapran (alexey.shapran@gmail.com)
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class eventActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
	public function executeIndex(sfWebRequest $request)
	{
		$q = Doctrine_Query::create()
		->select('*')
		->from('event')
		->orderBy('updated_at DESC');

	$this->pager = new sfDoctrinePager('event', sfConfig::get('app_maxeventperpage'));
	$this->pager->setQuery($q);
	$this->pager->setPage($request->getParameter('page',1));
	$this->pager->init();    
  }
  public function executeShownearest(sfWebRequest $request)
  {
  	$NUM_OF_EVENTS = 5;
  	
  	$q = Doctrine_Query::create()
    ->select('*')
    ->from('event')     
    ->where('updated_at<NOW()')
    ->orderBy('updated_at')
    ->limit($NUM_OF_EVENTS);
    
    $this->events = $q->execute();    
  }
  
  public function executeView(sfWebRequest $request)
  {
  	$this->event = $this->getRoute()->getObject();
	$this->forward404Unless($this->event);
	
		$response = $this->getResponse();
	
	$response->addMeta('keywords', $this->event['keywords']);
	$response->addMeta('description', $this->event['description']);
	$response->setTitle(sfConfig::get('app_title')." | ".$this->event['title']);
	
	$this->album = Album::retrieveAlbumToShow($this->event->getAlbumId());
	
  }
  
}
